#ifndef CONTROL_H
#define CONTROL_H

#include <QObject>
#include <QLineEdit>
#include <QWindow>
#include <QDBusInterface>
#include <QDBusReply>

#include <qpa/qplatforminputcontext.h>

class Control: public QObject
{
    Q_OBJECT

public:
    Control(QWindow *win, QObject *edit, QObject *parent = 0);
    ~Control();

signals:
    void Commit(const QString &string);
    void ForwardKey(const QString &key);

public slots:
    void ShowKeyboard();
    void HideKeyboard();
    void Reset(const QString &); //for fcitx

protected:
    bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;

private:
    QObject *m_edit;
    QWindow *m_focusWindow;
    QPlatformInputContext *m_imContext;

    QString m_previousCommit;
    QDBusInterface *m_interface; 
};

#endif // CONTROL_H
